import { defineStore } from 'pinia'

const useConfigStore = defineStore('config', {
    state: () => {
        return {
            theme: 'light',
            language: 'en',
            sidebar: {
                collapsed: false,
                show: true,
            },
            header: {
                show: true,
            },
            footer: {
                show: true,
            },
            menu: {
                show: true,
            },
            runInElectron: true,
            contextNum: 20,// 上下文数量
            openai: {
                model: 'gpt-3.5-turbo',
                defaultModel: 'gpt-3.5-turbo',
                max_tokens: 1024,// 最大token数量
                temperature: 0.6,// 随机属性
                top_p: 1,
                presence_penalty: 0,
                frequency_penalty: 0,
            },
            openaiConfig: {
                organization: '',
                apiKey: '',
                proxyUrl: '',
                defaultUrl: 'https://api.openai.com/v1',
            },
        }

    },
    actions: {
        setConfig(config) {
            this.$patch(config);
            return true;
        }
    },
    getters: {
        getConfig() {
            const config = {
                theme: this.theme,
                language: this.language,
                sidebar: this.sidebar,
                header: this.header,
                footer: this.footer,
                menu: this.menu,
                openai: this.openai,
                openaiConfig: this.openaiConfig,
            }
            return JSON.parse(JSON.stringify(config))
        }
    }
})

export default useConfigStore